﻿using System;
using DMS.Business.Utility;
using System.Data;

namespace DMS.Business.Modules.Organization
{
    /// <summary>
    /// 参与成员
    /// </summary>
    [Serializable]
    public abstract class Actor : IActor
    {
        #region 数据成员/内部成员
        internal DataRow _Data = null;
        /// <summary>
        /// 唯一标识编码
        /// </summary>
        protected string _ID;
        /// <summary>
        /// 名称
        /// </summary>
        protected string _Name;
        /// <summary>
        /// 成员范围（只用于角色成员那，比较恶心，赶时间）
        /// </summary>
        private string _MemberScope = string.Empty;
        #endregion

        #region 公共属性
        /// <summary>
        /// 唯一标识编码
        /// </summary>
        public string ID
        {
            get
            {
                return this._ID;
            }
            set
            {
                this._ID = value;
            }
        }
        /// <summary>
        /// 名称
        /// </summary>
        public string Name
        {
            get
            {
                return this._Name;
            }
            set
            {
                this._Name = value;
            }
        }
        /// <summary>
        /// 类型
        /// </summary>
        public abstract ActorTypes ActorType
        {
            get;
            set;
        }
        /// <summary>
        /// 成员范围
        /// </summary>
        public virtual string MemberScope
        {
            get
            {
                return this._MemberScope;
            }
            set
            {
                this._MemberScope = value;
            }
        }
        #endregion

        #region 构造函数
        public Actor()
        {
        }
        public Actor(string id)
        {
            this._ID = id;
        }
        #endregion

        #region 成员方法
        /// <summary>
        /// 多个角色名用;隔开。比如“物资管理员;系统管理员”
        /// </summary>
        /// <param name="roleName"></param>
        /// <returns></returns>
        public bool IsInRole(string roleName)
        {
            return UserHelper.IsUserInRole(this, roleName);
        }
        #endregion

        #region 系统内置角色判断
        /// <summary>
        /// 是否供应商
        /// </summary>
        public bool IsSupplier
        {
            get
            {
                return IsInRole("Supplier;SupplierAccount");
            }
        }
        /// <summary>
        /// 是否系统管理员
        /// </summary>
        public bool IsSystemManager
        {
            get
            {
                return IsInRole("系统管理员");
            }
        }
        /// <summary>
        /// 是否室经理
        /// </summary>
        public virtual bool IsManager
        {
            get
            {
                return IsInRole("室经理");
            }
        }

        /// <summary>
        /// 是否物资管理室经理
        /// </summary>
        public virtual bool IsWZSManager
        {
            get
            {
                return false;
            }
        }

        /// <summary>
        /// 是否物资申请员
        /// </summary>
        public bool IsMaterialApplier
        {
            get
            {
                return IsInRole("物资申请员");
            }
        }

        /// <summary>
        /// 是否物资管理员
        /// </summary>
        public bool IsMaterialManager
        {
            get
            {
                return IsInRole("物资管理员");
            }
        }

        /// <summary>
        /// 是否行政服务中心仓库管理员
        /// </summary>
        public bool IsStockManager
        {
            get
            {
                return IsInRole("行政服务中心仓库管理员");
            }
        }

        /// <summary>
        /// 是否综合员
        /// </summary>
        public bool IsVersatilePerson
        {
            get
            {
                return IsInRole("综合员");
            }
        }

        
        /// <summary>
        /// 是否渠道资产申请员
        /// </summary>
        public bool IsChannelApplier
        {
            get
            {
                return IsInRole("渠道资产申请员");
            }
        }
        /// <summary>
        /// 是否微区域总监
        /// </summary>
        public bool IsRegionDirector
        {
            get
            {
                return IsInRole("微区域总监");
            }
        }

        /// <summary>
        /// 是否部门经理
        /// </summary>
        public bool IsDeptManager
        {
            get
            {
                return IsInRole("部门经理");
            }
        }

        /// <summary>
        /// 是否分公司领导
        /// </summary>
        public bool IsCompanyLeader
        {
            get
            {
                return IsInRole("部门领导");
            }
        }

        #endregion
    }
}
